package edu.arizona.sista.learn.activity.fluents.paths;

import java.util.Vector;

import edu.arizona.sista.learn.activity.model.args.PredAgent;
import edu.arizona.sista.learn.activity.model.args.PredArg;
import edu.arizona.sista.learn.activity.model.args.PredObject;

public class SceneEntity {
	private String type;
	private int id;
	private String name;
	private Path3D path;
	private Vector<SceneEntity> attached;
	
	public SceneEntity(String type, int id, int numFrames) {
		this.type = type;
		this.id = id;
		setName(type+id);
		setPath(new Path3D(numFrames));
		
		Vector<SceneEntity> attached = new Vector<SceneEntity>();
		for (int i = 0; i < numFrames; i++) {
			attached.add(null);
		}
		setAttached(attached);
	}
	
	public SceneEntity(String type, String id, int numFrames) {
		this(type, Integer.parseInt(id), numFrames);
	}
	
	@Override
	public String toString() {
		return "<SceneEntity(\"" + type + "\", " + id + ")>";
	}
	
	@Override
	public boolean equals(Object o) {
		SceneEntity e = (SceneEntity) o;
		return getType().equals(e.getType()) && getId() == e.getId();
	}

	public String getType() {
		return type;
	}
	
	public void setName(String n) {
		this.name = n;
	}

	public int getId() {
		return id;
	}

	public void setPath(Path3D path) {
		this.path = path;
	}

	public Path3D getPath() {
		return path;
	}
	
	public Point3D getPoint(int i) {
		return path.getPoint(i);
	}
	
	public void setPoint(int i, String x, String y, String z) {
		path.setPoint(i, x, y, z);
	}
	
	public void setPoint(int i, double x, double y, double z) {
		path.setPoint(i, x, y, z);
	}
	
	public void setPoint(int i, Point3D p) {
		path.setPoint(i, p);
	}
	
	public String getName() {
		return name;
	}
	
	public PredArg getPredArg() {
		if (getType().compareTo("person") == 0) {
			return new PredAgent(null, getName());
		}
		else {
			return new PredObject(null, getName());
		}
	}

	public void setAttached(Vector<SceneEntity> attached) {
		this.attached = attached;
	}

	public Vector<SceneEntity> getAttached() {
		return attached;
	}
	
	public void attach(int i, SceneEntity e) {
		attached.set(i, e);
	}
	
	public SceneEntity getAttachedEntity(int i) {
		return attached.get(i);
	}
}
